Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Object.hash instead of hashValues #1431

Merged
merged 3 commits into from
Jan 10, 2025

Conversation

irvine5k
Copy link
Contributor

@irvine5k irvine5k commented Dec 13, 2024

The new Flutter stable version (3.27.0) bumps the version of Dart, and the new version removed the function hashValues which breaks apps that just upgraded to Flutter 3.27.0.

It's recommended to move to Object.hash

flutter/flutter#96109

@irvine5k irvine5k changed the title Use Object.all instead of hashValues Use Object.hashAll instead of hashValues Dec 13, 2024
@irvine5k
Copy link
Contributor Author

Fixes #1430

@felix-ht
Copy link
Collaborator

felix-ht commented Dec 16, 2024

can you remove all formatting changes? Maybe also go with Object.hash instead of Object.hashAll as the former is a one to one replacement of the current function.

@irvine5k irvine5k had a problem deploying to ANDROID_CI_DOWNLOADS_TOKEN December 16, 2024 15:29 — with GitHub Actions Failure
@irvine5k irvine5k had a problem deploying to ANDROID_CI_DOWNLOADS_TOKEN December 16, 2024 15:29 — with GitHub Actions Failure
@irvine5k
Copy link
Contributor Author

@felix-ht you're correct, I misread and it's Object.hash. I removed the formatting changes as well.

@irvine5k irvine5k changed the title Use Object.hashAll instead of hashValues Use Object.hash instead of hashValues Dec 16, 2024
@TBA-Lucas
Copy link

I'm getting an error on animateCamera using this PR, no idea if it is from the changes, the new flutter version or the way I added the PR to the dependencies (#1430 (comment)).

Uncaught Error: Null check operator used on a null value
    at mapbox_web_gl_platform.dart:209:18
    at _wrapJsFunctionForAsync_closure.$protected (async_patch.dart:311:19)
    at _wrapJsFunctionForAsync_closure.call$2 (async_patch.dart:336:23)
    at Object._asyncStartSync (async_patch.dart:241:3)
    at MapboxWebGlPlatform.animateCamera$body$MapboxWebGlPlatform (mapbox_web_gl_platform.dart:200:11)
    at MapboxWebGlPlatform.animateCamera$2$duration (mapbox_web_gl_platform.dart:200:11)
    at controller.dart:298:12
    at _wrapJsFunctionForAsync_closure.$protected (async_patch.dart:311:19)
    at _wrapJsFunctionForAsync_closure.call$2 (async_patch.dart:336:23)
    at Object._asyncStartSync (async_patch.dart:241:3)

(Weirdly enough the error is only happening in --profile or --release mode)

@irvine5k
Copy link
Contributor Author

irvine5k commented Dec 20, 2024

@TBA-Lucas It doesn't seem to be related to this PR. Seems that the around property is null at some point and it's being grabbed via JS, it has nothing to do (I guess so) with the hashValues -> Object.hash change.

@felix-ht do you anything about it?

  @override
  Future<bool?> animateCamera(CameraUpdate cameraUpdate,
      {Duration? duration}) async {
    final cameraOptions = Convert.toCameraOptions(cameraUpdate, _map);

    final around = getProperty(cameraOptions, 'around');
    final bearing = getProperty(cameraOptions, 'bearing');
    final center = getProperty(cameraOptions, 'center');
    final pitch = getProperty(cameraOptions, 'pitch');
    final zoom = getProperty(cameraOptions, 'zoom');

    _map.flyTo({
      if (around.jsObject != null) 'around': around,  // around is probably null at some point.
      if (bearing != null) 'bearing': bearing,
      if (center.jsObject != null) 'center': center,
      if (pitch != null) 'pitch': pitch,
      if (zoom != null) 'zoom': zoom,
      if (duration != null) 'duration': duration.inMilliseconds,
    });

    return true;
  }

@ArslanNaveed-cloud
Copy link

This issue causing a lot of problems with new flutter version.

Please update the package and merge this PR.

@moshOntong-IT
Copy link

When this can be merged?

@moshOntong-IT
Copy link

/C:/Users/asnaw/AppData/Local/Pub/Cache/git/flutter-mapbox-gl-b2bfef669e42397704b6f43d55b5df67b18c0fa8/mapbox_gl_platform_interface/lib/src/camera.dart:83:23: Error: The method 'hashValues' isn't defined for the class 'CameraPosition'.
 - 'CameraPosition' is from 'package:mapbox_gl_platform_interface/mapbox_gl_platform_interface.dart' ('/C:/Users/asnaw/AppData/Local/Pub/Cache/git/flutter-mapbox-gl-b2bfef669e42397704b6f43d55b5df67b18c0fa8/mapbox_gl_platform_interface/lib/mapbox_gl_platform_interface.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hashValues'.
  int get hashCode => hashValues(bearing, target, tilt, zoom);
                      ^^^^^^^^^^
/C:/Users/asnaw/AppData/Local/Pub/Cache/git/flutter-mapbox-gl-b2bfef669e42397704b6f43d55b5df67b18c0fa8/mapbox_gl_platform_interface/lib/src/location.dart:56:23: Error: The method 'hashValues' isn't defined for the class 'LatLng'.
 - 'LatLng' is from 'package:mapbox_gl_platform_interface/mapbox_gl_platform_interface.dart' ('/C:/Users/asnaw/AppData/Local/Pub/Cache/git/flutter-mapbox-gl-b2bfef669e42397704b6f43d55b5df67b18c0fa8/mapbox_gl_platform_interface/lib/mapbox_gl_platform_interface.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hashValues'.
  int get hashCode => hashValues(latitude, longitude);
                      ^^^^^^^^^^
/C:/Users/asnaw/AppData/Local/Pub/Cache/git/flutter-mapbox-gl-b2bfef669e42397704b6f43d55b5df67b18c0fa8/mapbox_gl_platform_interface/lib/src/location.dart:109:23: Error: The method 'hashValues' isn't defined for the class 'LatLngBounds'.
 - 'LatLngBounds' is from 'package:mapbox_gl_platform_interface/mapbox_gl_platform_interface.dart' ('/C:/Users/asnaw/AppData/Local/Pub/Cache/git/flutter-mapbox-gl-b2bfef669e42397704b6f43d55b5df67b18c0fa8/mapbox_gl_platform_interface/lib/mapbox_gl_platform_interface.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hashValues'.
  int get hashCode => hashValues(southwest, northeast);
                      ^^^^^^^^^^
/C:/Users/asnaw/AppData/Local/Pub/Cache/git/flutter-mapbox-gl-b2bfef669e42397704b6f43d55b5df67b18c0fa8/mapbox_gl_platform_interface/lib/src/location.dart:167:23: Error: The method 'hashValues' isn't defined for the class 'LatLngQuad'.
 - 'LatLngQuad' is from 'package:mapbox_gl_platform_interface/mapbox_gl_platform_interface.dart' ('/C:/Users/asnaw/AppData/Local/Pub/Cache/git/flutter-mapbox-gl-b2bfef669e42397704b6f43d55b5df67b18c0fa8/mapbox_gl_platform_interface/lib/mapbox_gl_platform_interface.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hashValues'.
  int get hashCode => hashValues(topLeft, topRight, bottomRight, bottomLeft);
                      ^^^^^^^^^^
/C:/Users/asnaw/AppData/Local/Pub/Cache/git/flutter-mapbox-gl-b2bfef669e42397704b6f43d55b5df67b18c0fa8/mapbox_gl_platform_interface/lib/src/ui.dart:146:23: Error: The method 'hashValues' isn't defined for the class 'MinMaxZoomPreference'.
 - 'MinMaxZoomPreference' is from 'package:mapbox_gl_platform_interface/mapbox_gl_platform_interface.dart' ('/C:/Users/asnaw/AppData/Local/Pub/Cache/git/flutter-mapbox-gl-b2bfef669e42397704b6f43d55b5df67b18c0fa8/mapbox_gl_platform_interface/lib/mapbox_gl_platform_interface.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hashValues'.
  int get hashCode => hashValues(minZoom, maxZoom);
                      ^^^^^^^^^^
Target kernel_snapshot_program failed: Exception
2

FAILURE: Build failed with an exception.

Is this related on your PR?

@irvine5k
Copy link
Contributor Author

irvine5k commented Jan 5, 2025

@moshOntong-IT maybe it’s due the fact that the inner packages points to this repository which is broken while I fixed locally pointing to my branch which has the fix, but I can’t make this PR points to my branch.

Tldr: my PR should be merged

@irvine5k
Copy link
Contributor Author

irvine5k commented Jan 5, 2025

Could you review it again when possible? I’d appreciate it @felix-ht

@irvine5k irvine5k had a problem deploying to ANDROID_CI_DOWNLOADS_TOKEN January 10, 2025 14:18 — with GitHub Actions Failure
@irvine5k irvine5k had a problem deploying to ANDROID_CI_DOWNLOADS_TOKEN January 10, 2025 14:18 — with GitHub Actions Failure
Copy link
Collaborator

@felix-ht felix-ht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@felix-ht felix-ht merged commit d4aee36 into flutter-mapbox-gl:master Jan 10, 2025
4 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants